<div class="maintop">
    当前位置：发包记录
    <a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($page_current,$page_url)?>" id="btn_refresh" class="mainFrame button">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
</div>
<div class="main-search">
    <table width="100%">

        <tbody><tr>
            <td>
                <form action="<?=$basepath?>" id="brandsSearch" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                    &nbsp;<select name="field">
                        <option value="">全部</option>
                        <option value="uno">玩家号码</option>
                    </select>
                    <select name="bankid">
                        <option value="">全部银行</option>
                        <? foreach ($banks as $bk=>$bv){
                            echo '<option value="'.$bk.'">'.$bv.'</option>';
                        }
                        ?>
                    </select>
                    <select name="state">
                        <option value="">全部状态</option>
                        <? foreach ($this->cashState as $k=>$v){
                            echo '<option value="'.$k.'">'.$v.'</option>';
                        }
                        ?>
                    </select>
                    日期：从
                    <input id="fromTime" name="fromTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['fromTime']?date('Y-m-d',intval(strtotime($searchdata['fromTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;至
                    <input id="toTime" name="toTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['toTime']?date('Y-m-d',intval(strtotime($searchdata['toTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;&nbsp;
                    <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字">
                    每页：
                    <select id="ps" name="ps">
                        <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                        <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                        <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                        <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                        <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                    </select>
                    <input type="submit" value="搜索" class="upbutton">
                </form>
            </td>
        </tr>
        </tbody>

    </table>
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg">
            <th>No.</th>
            <th>玩家号码</th>
            <th>玩家昵称</th>
            <th>玩家余额</th>
            <th>开户行</th>
            <th>帐号姓名</th>
            <th>帐号</th>
            <th>帐号地址</th>
            <th>提现金额</th>
            <th width="140">日期时间</th>
            <th width="60" colspan="3">操作</th>
        </tr>
        <?
        $pagecoin = 0;

        foreach($datas as $v){
            $pagecoin += $v['amount'];
            ?>
            <tr>
                <td><?=$v['id']?></td>
                <td><a href="/members/members_list_edit?uid=<?=$v['uid']?>" title="编辑" class="colorbox"><?=$v['uno']?></a></td>
                <td><?=$v['nickname']?></td>
                <td><?=$v['coin']?></td>
                <td><?=$banks[$v['bid']]?></td>
                <td><?=$v['name']?></td>
                <td><?=$v['account']?></td>
                <td style="text-align:left"><?=$v['openadds']?></td>
                <td><?=$v['amount']?></td>
                <td><?=date('Y-m-d H:i:s',$v['cashtime'])?></td>
                <? if(intval($v['state'])==0){ ?>
                <td width="30">
                    <a  title="提现成功" class="mainFrame button icon-ok" href="javascript:;" onclick="f('<?=$basepath?>_success?id=<?=$v['id']?>')"></a>
                </td>
                <td width="60"><a href="javascript:;" class="upbutton state<?=$v['state']?>"><?=$this->cashState[$v['state']]?></a></td>
                <td width="30">
                    <a action="<?=$basepath?>_faild?id=<?=$v['id']?>&cashid=<?=$v['cashid']?>" title="提现失败" class="mainFrame button icon-cancel" href="javascript:;"></a>
                </td>
                <? }else{
                    if($v['state']==1){
                    ?>
                    <td colspan="3"><a href="javascript:;" class="upbutton state<?=$v['state']?>"><?=$this->cashState[$v['state']]?></a></td>
                <? }else{ ?>
                    <td colspan="3"><a href="javascript:;" class="upbutton state<?=$v['state']?>"><?=$v['info']?></a></td>
                <?    }
                } ?>
            </tr>
        <? } ?>
        <tr><td colspan="7">本页合计</td><td><?=$this->formatCoin($pagecoin)?></td><td colspan="5"></td></tr>
        <tr><td colspan="7">当前统计</td><td><?=$this->formatCoin($total['amount'])?></td><td colspan="5"></td></tr>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){
        var _key = this.sKey.value;
        if(_key.length<=0){
            //throw '搜索关键字不能为空';
        }
    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        if(!empty($searchdata['field'])){
            echo '$("select[name=\'field\'] option[value=\''.$searchdata['field'].'\']").attr("selected", "selected");';
        }
        if(!empty($searchdata['bankid'])){
            echo '$("select[name=\'bankid\'] option[value=\''.$searchdata['bankid'].'\']").attr("selected", "selected");';
        }
        if($searchdata['state']!=''){
            echo '$("select[name=\'state\'] option[value=\''.$searchdata['state'].'\']").attr("selected", "selected");';
        }
        ?>
        $(".colorbox").colorbox({ iframe: true,width:"80%",height:"80%" });
    });

    function f(action) {
        if( confirm('正在确认提现，是否继续执行？') ){
            $.get(action,function (data,textStatus, xhr) {
                $.dialogue(null);
                var error_message = xhr.getResponseHeader('X-Error-Message');
                if (error_message) {
                    loadpage.close();
                    if (error_message === 'dialogue') {
                        var obj = eval('(' + data + ')');
                        $.dialogue(obj);
                    } else {
                        $.error(decodeURIComponent(error_message));
                    }
                }
            });
        }

    }
</script>
